<template>
  <div class="app-container">
    <el-form
      v-show="showSearch"
      ref="queryForm"
      :model="queryParams"
      :inline="true"
      label-width="85px"
    >
      <el-form-item label="公司名称:" prop="compName">
        <el-input
          v-model="queryParams.compName"
          placeholder="请输入公司名称"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="母公司:" prop="parCompName">
        <el-input
          v-model="queryParams.parCompName"
          placeholder="请输入公司名称"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>

      <el-form-item label="省:" prop="province">
        <el-input
          v-model="queryParams.province"
          placeholder="请输入地址"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <br />
      <el-form-item label="市:" prop="city">
        <el-input
          v-model="queryParams.city"
          placeholder="请输入地址"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>

      <el-form-item label="显示入库:" prop="isMyCustomer">
        <el-select
          v-model="queryParams.isMyCustomer"
          placeholder="入库状态"
          clearable
          size="small"
          @change="handleQuery"
        >
          <el-option label="全部" value="" />
          <el-option label="是" value="true" />
          <el-option label="否" value="false" />
        </el-select>
      </el-form-item>
      <el-form-item label="显示删除:" prop="isDeleted">
        <el-select
          v-model="queryParams.isDeleted"
          placeholder="是否删除"
          clearable
          size="small"
          @change="handleQuery"
        >
          <el-option label="全部" value="" />
          <el-option label="是" value="true" />
          <el-option label="否" value="false" />
        </el-select>
      </el-form-item>
      <el-form-item>
        <el-button
          type="primary"
          icon="el-icon-search"
          size="mini"
          @click="handleQuery"
        >搜索</el-button>
        <el-button
          icon="el-icon-refresh"
          size="mini"
          @click="resetQuery"
        >重置</el-button>
      </el-form-item>
    </el-form>
    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="el-icon-plus"
          size="mini"
          @click="handleAdd"
        >新增</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="el-icon-download"
          size="mini"
          @click="handleExport"
        >导出</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-delete"
          size="mini"
          :disabled="multiple"
          @click="handleDelete"
        >删除</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="success"
          plain
          icon="el-icon-upload"
          size="mini"
          :disabled="multiple || !canAddInfo"
          @click="batchImport"
        >批量入库</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="danger"
          plain
          icon="el-icon-upload"
          size="mini"
          :disabled="multiple || !canExpInfo"
          @click="batchExport"
        >批量出库</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="danger"
          plain
          icon="el-icon-upload"
          size="mini"
          :disabled="!kqAllInfoList.length"
          :loading="orderSearchLoading"
          @click="orderSearch"
        >订单查询</el-button>
      </el-col>

      <right-toolbar :show-search.sync="showSearch" @queryTable="getList" />
    </el-row>

    <el-table
      v-loading="loading"
      :data="kqAllInfoList"
      stripe
      height="630"
      @selection-change="handleSelectionChange"
      @row-dblclick="handleOrderView"
    >
      <el-table-column type="selection" />
      <el-table-column type="index" width="40" />
      <el-table-column label="母公司" show-overflow-tooltip min-width="100">
        <template slot-scope="scope">
          <div>
            <el-button
              v-if="scope.row.parCompName"
              size="mini"
              type="text"
              icon="el-icon-document-copy"
              @click="CopyFileUrl(scope.row.parCompName)"
            /> &nbsp;<el-link
              target="_blank"
              :href="
                'https://www.tianyancha.com/search?key=' + scope.row.parCompName
              "
            >
              {{ scope.row.parCompName }}
            </el-link>
          </div>

        </template>
      </el-table-column>
      <el-table-column label="公司名称" show-overflow-tooltip min-width="150">
        <template slot-scope="scope">
          <div>
            <el-button
              v-if="scope.row.compName"
              size="mini"
              type="text"
              icon="el-icon-document-copy"
              @click="CopyFileUrl(scope.row.compName)"
            /> &nbsp;<el-link
              target="_blank"
              :href="
                'https://www.tianyancha.com/search?key=' + scope.row.compName
              "
            >
              {{ scope.row.compName }}
            </el-link>
          </div>

        </template>
      </el-table-column>
      <el-table-column label="参保人数" prop="empNum" />
      <el-table-column label="实缴资本" prop="realCap" />

      <el-table-column label="网站" prop="url" show-overflow-tooltip>
        <template slot-scope="scope">
          <el-link target="_blank" :href="scope.row.url">
            {{ scope.row.url }}
          </el-link>
        </template>
      </el-table-column>
      <!-- <el-table-column label="所属行业" prop="classify">
        <template slot-scope="scope">
          {{ scope.row.classify||'-' }}
        </template>
      </el-table-column> -->
      <!-- <el-table-column label="合作业务员" prop="collaborator">
        <template slot-scope="scope">
          {{ scope.row.collaborator || "-" }}
        </template>
      </el-table-column> -->
      <el-table-column label="省/市/区县" prop="province" show-overflow-tooltip>
        <template slot-scope="scope">
          <span>{{ scope.row.province }}/{{ scope.row.city }}/{{
            scope.row.district
          }}</span>
        </template>
      </el-table-column>
      <el-table-column label="入库操作">
        <template slot-scope="scope">
          <el-button
            v-if="scope.row.isMyCustomer"
            size="mini"
            type="danger"
            icon="el-icon-upload"
            @click="handleAsync(scope.row, false)"
          >出库</el-button>

          <el-button
            v-if="!scope.row.isMyCustomer"
            :disabled="scope.row.isDeleted"
            size="mini"
            type="success"
            icon="el-icon-upload"
            @click="handleAsync(scope.row, true)"
          >入库</el-button>
        </template>
      </el-table-column>
      <el-table-column
        label="操作"
        align="center"
        width="150"
        class-name="small-padding"
      >
        <template slot-scope="scope">
          <el-button
            type="primary"
            icon="el-icon-edit"
            circle
            @click="handleUpdate(scope.row)"
          ></el-button>
          <el-button
            v-if="!scope.row.isDeleted && !scope.row.isMyCustomer"
            type="primary"
            icon="el-icon-delete"
            circle
            @click="handleDelete(scope.row)"
          ></el-button>
          <el-button
            v-if="scope.row.isDeleted"
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="recoveryData(scope.row.id)"
          >恢复</el-button>
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total > 0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      :page-sizes="[10,50,100, 200,500]"
      @pagination="getList"
    />

    <el-dialog
      :title="orderTitle"
      :visible.sync="openOrder"
      append-to-body
      width="80%"
      center
    >
      <el-table :data="kqAllOrderList" height="500" border stripe>
        <el-table-column type="index" width="38" />
        <el-table-column prop="orderDate" label="日期" width="100" />
        <el-table-column prop="maxDepartment" label="大区" />
        <el-table-column prop="department" label="部门" />
        <el-table-column prop="collaborator" label="业务员" />
        <el-table-column prop="position" label="职位" />
        <el-table-column prop="sex" label="性别" />
        <el-table-column prop="isEmployed" label="是否在职">
          <template slot-scope="scope">
            {{ scope.row.isEmployed?'是':'否' }}
          </template>
        </el-table-column>
        <el-table-column prop="projectName" label="项目名称" />
        <el-table-column prop="dealNum" label="成交额(万)">
          <template slot-scope="scope">
            {{ scope.row.dealNum / 10000 }}
          </template>
        </el-table-column>
        <el-table-column prop="products" label="采购信息" />
        <el-table-column prop="orderType" label="类型" />
      </el-table>
    </el-dialog>
    <el-dialog
      title="所有订单"
      :visible.sync="openOrderLen"
      append-to-body
      width="80%"
      center
    >
      <el-table :data="orderLenList" height="500" style="width: 100%" border stripe>
        <el-table-column type="index" width="38" />
        <el-table-column prop="compName" label="公司名称" :show-overflow-tooltip="true">
          <template slot-scope="scope">
            <div>
              <el-button
                v-if="scope.row.compName"
                size="mini"
                type="text"
                icon="el-icon-document-copy"
                @click="CopyFileUrl(scope.row.compName)"
              />&nbsp;
              <el-link
                target="_blank"
                :href="
                  'https://www.tianyancha.com/search?key=' + scope.row.compName
                "
              >
                {{ scope.row.compName }}
              </el-link>
            </div>

          </template>
        </el-table-column>
        <el-table-column prop="orderLen" label="订单数量" sortable />

      </el-table>
    </el-dialog>
    <!-- 添加或修改岗位对话框 -->
    <el-drawer
      :title="title"
      :visible.sync="open"
      size="70%"
      :with-header="true"
    >
      <el-form ref="form" :model="form" :rules="rules" label-width="80px">
        <el-row>
          <el-col :span="8">
            <el-form-item label-width="100px" label="公司名称:" prop="compName">
              <el-input v-model="form.compName" placeholder="请输入公司名称" />
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label-width="100px" label="公司法人:" prop="compOwner">
              <el-input v-model="form.compOwner" placeholder="请输入公司法人" />
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label-width="100px" label="母公司:" prop="parCompName">
              <el-input v-model="form.parCompName" placeholder="请输入母公司名称" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="8">
            <el-form-item label-width="100px" label="省份:" prop="province">
              <el-input v-model="form.province" placeholder="省份" />
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label-width="100px" label="地市:" prop="city">
              <el-input v-model="form.city" placeholder="地市" />
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label-width="100px" label="区县:" prop="district">
              <el-input v-model="form.district" placeholder="区县" />
            </el-form-item>
          </el-col>
        </el-row>

        <el-row>
          <el-col :span="8">
            <el-form-item label-width="100px" label="参保人数:" prop="empNum">
              <el-input v-model="form.empNum" placeholder="参保人数" />
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label-width="100px" label="详细地址:" prop="address">
              <el-input v-model="form.address" placeholder="详细地址" />
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item
              label-width="100px"
              label="街道/乡镇:"
              prop="street"
            >
              <el-input
                v-model="form.street"
                placeholder="请输入街道/乡镇"
              />
            </el-form-item>
          </el-col>

        </el-row>

        <el-row>
          <el-col :span="8">
            <el-form-item label-width="100px" label="公司类型:" prop="compType">
              <el-input v-model="form.compType" placeholder="公司类型" />
            </el-form-item>
          </el-col>

          <el-col :span="8">
            <el-form-item label-width="100px" label="曾用名:" prop="oldName">
              <el-input v-model="form.oldName" placeholder="曾用名" />
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label-width="100px" label="经营状态:" prop="opStatus">
              <el-input v-model="form.opStatus" placeholder="请输入经营状态" />
            </el-form-item>
          </el-col>
        </el-row>

        <el-row>
          <el-col :span="8">
            <el-form-item label-width="100px" label="成立日期:" prop="foundDay">
              <el-date-picker v-model="form.foundDay" type="date" placeholder="请输入成立日期" />
            </el-form-item>
          </el-col>

          <el-col :span="8">
            <el-form-item label-width="100px" label="联系电话:" prop="phone">
              <el-input v-model="form.phone" placeholder="联系电话" />
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item
              label-width="100px"
              label="其他电话:"
              prop="otherPhone"
            >
              <el-input v-model="form.otherPhone" placeholder="其他电话" />
            </el-form-item>
          </el-col>
        </el-row>

        <el-row>
          <el-col :span="8">
            <el-form-item label-width="100px" label="注册资本:" prop="regCap">
              <el-input v-model="form.regCap" placeholder="请输入注册资本" />
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label-width="100px" label="实缴资本:" prop="realCap">
              <el-input v-model="form.realCap" placeholder="请输入实缴资本" />
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label-width="100px" label="邮箱:" prop="email">
              <el-input v-model="form.email" placeholder="邮箱" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col>
            <el-form-item label-width="100px" label="网址:" prop="url">
              <el-input v-model="form.url" placeholder="网址" />
            </el-form-item>
          </el-col>
        </el-row>

        <el-row>
          <el-col :span="22">
            <el-form-item
              label-width="100px"
              label="经营范围:"
              prop="businessScope"
            >
              <el-input
                v-model="form.businessScope"
                minlength="500"
                type="textarea"
                placeholder="经营范围"
                :rows="5"
              />
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
      <div style="text-align: center;">
        <el-button
          v-if="isShowDetail"
          type="primary"
          @click="submitForm"
        >确 定</el-button>
        <el-button @click="handleCancel">取 消</el-button>
      </div>
    </el-drawer>
  </div>
</template>

<script>
import {
  listKqAllInfos,
  getKqInfo,
  batchDeleteKqInfo,
  addKqInfo,
  updateKqInfo,
  updateKqInfoStatus,
  batchUpdateKqInfo,
  exportKqAllInfos,
  recoverKqInfo
} from "@/api/work/work";

import { getAllKqOrdersList } from "@/api/work/allKqOrders";

export default {
  name: "Work",
  data() {
    return {
      // 遮罩层
      loading: true,
      // tab
      tabIndex: "first",
      // 选中数组
      ids: [],
      // importList
      importList: [],
      // exportList
      exportList: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 是否可以入库
      canAddInfo: false,
      // 是否可以出库
      canExpInfo: false,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 岗位表格数据
      kqAllInfoList: [],
      // 订单表格数据
      kqAllOrderList: [],
      orderLenList: [],
      // 弹出层标题
      title: "",
      // 订单标题
      orderTitle: "",
      // 是否显示弹出层
      open: false,
      // 是否显示订单弹出层
      openOrder: false,
      openOrderLen: false,
      // 是否显示数据详情页面
      isShowDetail: true,
      orderSearchLoading: false,
      //
      // cus_classify_option: [],
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        compName: undefined,
        province: undefined,
        city: undefined,
        parCompName: undefined,
        // district: undefined,
        isDeleted: "false",
        isMyCustomer: "true"
        // collaborator: undefined
      },
      // 表单参数
      form: {},
      // cus_rank_options: [
      // ],
      // 表单校验
      rules: {
        compName: [
          { required: true, message: "公司名称不能为空", trigger: "blur" }
        ],
        compOwner: [
          { required: true, message: "公司法人不能为空", trigger: "blur" }
        ],
        empNum: [
          { required: true, message: "参保人数不能为空", trigger: "blur" }
        ],
        opStatus: [
          { required: true, message: "经营状态不能为空", trigger: "blur" }
        ],
        province: [
          { required: true, message: "省份不能为空", trigger: "blur" }
        ],
        city: [{ required: true, message: "城市不能为空", trigger: "blur" }],
        district: [
          { required: true, message: "区县不能为空", trigger: "blur" }
        ],
        address: [{ required: true, message: "详细不能为空", trigger: "blur" }],
        businessScope: [
          { required: true, message: "经营范围不能为空", trigger: "blur" }
        ]
      }
    };
  },
  created() {
    this.getList();
  },
  methods: {
    /** 查询岗位列表 */
    getList() {
      this.loading = true;
      this.orderLenList = [];
      listKqAllInfos(this.queryParams).then((res) => {
        this.kqAllInfoList = res.data.results;
        this.total = res.data.count;
        this.loading = false;
      });
    },
    // 取消按钮
    handleCancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.isShowDetail = true;
      this.form = {
        id: undefined,
        compName: undefined,
        parCompName: undefined,
        compOwner: undefined,
        regCap: undefined,
        realCap: undefined,
        foundDay: undefined,
        opStatus: undefined,
        province: undefined,
        city: undefined,
        district: undefined,
        compType: undefined,
        // industry: undefined,
        oldName: undefined,
        empNum: undefined,
        phone: undefined,
        otherPhone: undefined,
        address: undefined,
        url: undefined,
        email: undefined,
        businessScope: undefined,
        isMyCustomer: false,
        businessProgress: undefined
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map((item) => item.id);
      this.importList = selection
        .filter((item) => !item.isMyCustomer)
        .map((one) => one.id);

      this.exportList = selection
        .filter((item) => item.isMyCustomer)
        .map((one) => one.id);

      this.single = selection.length != 1;
      this.multiple = !selection.length;
      this.canAddInfo = !!this.importList.length;
      this.canExpInfo = !!this.exportList.length;
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      this.title = "添加数据";
    },
    handleView(row) {
      this.reset();
      const id = row.id || this.ids;
      getKqInfo(id).then((response) => {
        this.form = response.data;
        this.open = true;
        this.title = "查看数据";
        this.isShowDetail = false;
      });
    },
    handleOrderView(row) {
      const compName = Object.prototype.toString.call(row) === "[object Object]" ? row.compName : "";
      const params = {
        pageNum: 1,
        pageSize: 100,
        compName
      };
      this.orderTitle = compName;
      getAllKqOrdersList(params).then((res) => {
        this.openOrder = true;
        this.kqAllOrderList = res.data.results;
      });
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      const id = row.id || this.ids;
      getKqInfo(id).then((response) => {
        this.form = response.data;
        this.open = true;
        this.title = "修改数据";
      });
    },
    /** 提交按钮 */
    submitForm: function() {
      this.$refs["form"].validate((valid) => {
        if (valid) {
          if (this.form.id != undefined) {
            updateKqInfo(this.form).then((response) => {
              this.msgSuccess("修改成功");
              this.open = false;
              this.getList();
            });
          } else {
            addKqInfo(this.form).then((response) => {
              this.msgSuccess("新增成功");
              this.open = false;
              this.getList();
            });
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const postIds = row.id ? [row.id] : this.ids;
      const msg = row.id ? row.compName : this.ids;
      this.$confirm(
        '是否确认删除岗位编号为"' + msg + '"的数据项?',
        "警告",
        {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning"
        }
      )
        .then(function() {
          return batchDeleteKqInfo(postIds);
        })
        .then(() => {
          this.getList();
          this.msgSuccess("删除成功");
        }).catch(() => {});
    },
    recoveryData(id) {
      this.$confirm("是否确认恢复这条数据？", "警告")
        .then(() => {
          return recoverKqInfo(id);
        })
        .then(() => {
          this.getList();
          this.msgSuccess("恢复成功！");
        });
    },
    /** 出库入库按钮操作 */
    handleAsync(row, isMyCustomer) {
      const data = {
        id: row.id,
        isMyCustomer
      };
      this.handleAddMyCusInfoFunc(data);
    },

    // 确定加入我的客户库？
    handleAddMyCusInfoFunc(data) {
      this.$confirm("执行次操作", "警告", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning"
      }).then(() => {
        updateKqInfoStatus(data)
          .then(() => {
            this.msgSuccess("操作成功！");
            this.getList();
          });
      });
    },

    batchImport() {
      this.handleAsyncStatusFunc(this.importList, true);
    },
    batchExport() {
      this.handleAsyncStatusFunc(this.exportList, false);
    },
    handleAsyncStatusFunc(batchList, isMyCustomerStatus) {
      const updateList = [];
      const list = [];
      batchList.forEach((id) => {
        const updateOne = this.kqAllInfoList.filter(
          (kqOne) => kqOne.id == id && !kqOne.isMyCustomer
        );
        list.push({
          id,
          isMyCustomer: isMyCustomerStatus
          // customRank:'0',
          // businessProgress:'0'
          // infoStatus
        });
        updateList.push(updateOne[0]);
      });
      this.$confirm("确定批量更新数据？", "警告", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning"
      }).then(() => {
        batchUpdateKqInfo(list)
          .then(() => {
            this.msgSuccess("批量更新数据成功！");
            this.getList();
          });
      });
    },
    orderSearch() {
      this.orderLenList = [];
      // const compNameList = this.kqAllInfoList.map(one => one.compName);
      const compNameList = this.kqAllInfoList;
      const searchLength = this.kqAllInfoList.length;
      this.orderSearchLoading = true;
      if (searchLength && searchLength < 51) {
        this.getOrderLenHandler(compNameList);
      } else if (searchLength > 50 && searchLength < 101) {
        this.getOrderLenHandler(compNameList.slice(0, 50));
        setTimeout(() => {
          this.getOrderLenHandler(compNameList.slice(50, compNameList.length));
        }, 10000);
      } else if (searchLength > 100 && searchLength < 151) {
        this.getOrderLenHandler(compNameList.slice(0, 50));
        setTimeout(() => {
          this.getOrderLenHandler(compNameList.slice(50, 100));
        }, 10000);
        setTimeout(() => {
          this.getOrderLenHandler(compNameList.slice(100, compNameList.length));
        }, 10000 * 2);
      } else if (searchLength > 150 && searchLength < 201) {
        this.getOrderLenHandler(compNameList.slice(0, 50));
        setTimeout(() => {
          this.getOrderLenHandler(compNameList.slice(50, 100));
        }, 10000);
        setTimeout(() => {
          this.getOrderLenHandler(compNameList.slice(100, 150));
        }, 10000 * 2);
        setTimeout(() => {
          this.getOrderLenHandler(compNameList.slice(150, compNameList.length));
        }, 10000 * 3);
      } else if (searchLength > 200 && searchLength < 251) {
        this.getOrderLenHandler(compNameList.slice(0, 50));
        setTimeout(() => {
          this.getOrderLenHandler(compNameList.slice(50, 100));
        }, 10000);
        setTimeout(() => {
          this.getOrderLenHandler(compNameList.slice(100, 150));
        }, 10000 * 2);
        setTimeout(() => {
          this.getOrderLenHandler(compNameList.slice(150, 200));
        }, 10000 * 3);
        setTimeout(() => {
          this.getOrderLenHandler(compNameList.slice(200, compNameList.length));
        }, 10000 * 4);
      } else if (searchLength > 250 && searchLength < 301) {
        this.getOrderLenHandler(compNameList.slice(0, 50));
        setTimeout(() => {
          this.getOrderLenHandler(compNameList.slice(50, 100));
        }, 10000);
        setTimeout(() => {
          this.getOrderLenHandler(compNameList.slice(100, 150));
        }, 10000 * 2);
        setTimeout(() => {
          this.getOrderLenHandler(compNameList.slice(150, 200));
        }, 10000 * 3);
        setTimeout(() => {
          this.getOrderLenHandler(compNameList.slice(200, 250));
        }, 10000 * 4);
        setTimeout(() => {
          this.getOrderLenHandler(compNameList.slice(250, compNameList.length));
        }, 10000 * 5);
      } else if (searchLength > 300 && searchLength < 351) {
        this.getOrderLenHandler(compNameList.slice(0, 50));
        setTimeout(() => {
          this.getOrderLenHandler(compNameList.slice(50, 100));
        }, 10000);
        setTimeout(() => {
          this.getOrderLenHandler(compNameList.slice(100, 150));
        }, 10000 * 2);
        setTimeout(() => {
          this.getOrderLenHandler(compNameList.slice(150, 200));
        }, 10000 * 3);
        setTimeout(() => {
          this.getOrderLenHandler(compNameList.slice(200, 250));
        }, 10000 * 4);
        setTimeout(() => {
          this.getOrderLenHandler(compNameList.slice(250, 300));
        }, 10000 * 5);
        setTimeout(() => {
          this.getOrderLenHandler(compNameList.slice(300, compNameList.length));
        }, 10000 * 6);
      } else if (searchLength > 350 && searchLength < 401) {
        this.getOrderLenHandler(compNameList.slice(0, 50));
        setTimeout(() => {
          this.getOrderLenHandler(compNameList.slice(50, 100));
        }, 10000);
        setTimeout(() => {
          this.getOrderLenHandler(compNameList.slice(100, 150));
        }, 10000 * 2);
        setTimeout(() => {
          this.getOrderLenHandler(compNameList.slice(150, 200));
        }, 10000 * 3);
        setTimeout(() => {
          this.getOrderLenHandler(compNameList.slice(200, 250));
        }, 10000 * 4);
        setTimeout(() => {
          this.getOrderLenHandler(compNameList.slice(250, 300));
        }, 10000 * 5);
        setTimeout(() => {
          this.getOrderLenHandler(compNameList.slice(300, 350));
        }, 10000 * 6);
        setTimeout(() => {
          this.getOrderLenHandler(compNameList.slice(350, compNameList.length));
        }, 10000 * 7);
      } else if (searchLength > 400 && searchLength < 451) {
        this.getOrderLenHandler(compNameList.slice(0, 50));
        setTimeout(() => {
          this.getOrderLenHandler(compNameList.slice(50, 100));
        }, 10000);
        setTimeout(() => {
          this.getOrderLenHandler(compNameList.slice(100, 150));
        }, 10000 * 2);
        setTimeout(() => {
          this.getOrderLenHandler(compNameList.slice(150, 200));
        }, 10000 * 3);
        setTimeout(() => {
          this.getOrderLenHandler(compNameList.slice(200, 250));
        }, 10000 * 4);
        setTimeout(() => {
          this.getOrderLenHandler(compNameList.slice(250, 300));
        }, 10000 * 5);
        setTimeout(() => {
          this.getOrderLenHandler(compNameList.slice(300, 350));
        }, 10000 * 6);
        setTimeout(() => {
          this.getOrderLenHandler(compNameList.slice(350, 400));
        }, 10000 * 7);
        setTimeout(() => {
          this.getOrderLenHandler(compNameList.slice(400, compNameList.length));
        }, 10000 * 8);
      } else if (searchLength > 450) {
        this.getOrderLenHandler(compNameList.slice(0, 50));
        setTimeout(() => {
          this.getOrderLenHandler(compNameList.slice(50, 100));
        }, 10000 * 1);
        setTimeout(() => {
          this.getOrderLenHandler(compNameList.slice(100, 150));
        }, 10000 * 2);
        setTimeout(() => {
          this.getOrderLenHandler(compNameList.slice(150, 200));
        }, 10000 * 3);
        setTimeout(() => {
          this.getOrderLenHandler(compNameList.slice(200, 250));
        }, 10000 * 4);
        setTimeout(() => {
          this.getOrderLenHandler(compNameList.slice(250, 300));
        }, 10000 * 5);
        setTimeout(() => {
          this.getOrderLenHandler(compNameList.slice(300, 350));
        }, 10000 * 6);
        setTimeout(() => {
          this.getOrderLenHandler(compNameList.slice(350, 400));
        }, 10000 * 7);
        setTimeout(() => {
          this.getOrderLenHandler(compNameList.slice(400, 450));
        }, 10000 * 8);
        setTimeout(() => {
          this.msgSuccess("检索完毕！！！！");
          this.getOrderLenHandler(compNameList.slice(450, compNameList.length));
        }, 10000 * 9);
      }

      setTimeout(() => {
        this.orderSearchLoading = false;
        this.openOrderLen = true;
      }, 3000);
    },
    getOrderLenHandler(compNameList) {
      compNameList.forEach(one => {
        getAllKqOrdersList({
          pageNum: 1,
          pageSize: 1000,
          compName: one?.compName
        }).then((res) => {
          this.orderLenList.push({
            id: one?.id,
            isMyCustomer: one?.isMyCustomer,
            compName: one?.compName,
            orderLen: res.data.results.length,
            businessProgress: one?.businessProgress
          });
        });
      });
    },
    CopyFileUrl(values) {
      const input = document.createElement("input");
      document.body.appendChild(input);
      input.setAttribute("value", values);
      input.select();
      if (document.execCommand("copy")) {
        document.execCommand("copy");
        this.msgSuccess("复制成功");
      }
      document.body.removeChild(input);
    },
    /** 导出按钮操作 */
    handleExport() {
      const queryParams = this.queryParams;
      this.$confirm("是否确认导出所有岗位数据项?", "警告", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning"
      })
        .then(function() {
          return exportKqAllInfos(queryParams);
        })
        .then((response) => {
          this.download(response.data.file_url, response.data.name);
        });
    }
  }
};
</script>
